package com.study.servlet;

import com.study.entity.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;

@WebServlet(name = "list",urlPatterns = "/list")
public class ListServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ArrayList<User> list=new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            list.add(new User("User"+i, "Name"+i,i*2+20, i%2, i%2==0?"女":"男",""+i+i+i+"@qq.com",new Date(), "这里是简介"));
        }
        req.setAttribute("list",list);
        req.getRequestDispatcher("/homework/jsps/list.jsp").forward(req,resp);
    }
}
